package com.homework16;

import java.io.File;
import java.util.Scanner;

public class demo01 {
    public static void main(String[] args) {
        String s = new Scanner(System.in).nextLine();
        File file = new File(s);
        if(file.exists() && file.isDirectory()){
            long result = calculate(file);
            System.out.println(result);
        }else{
            System.out.println("该目录不存在或不是一个文件夹");
        }
    }

    private static Long calculate(File file) {
        long size=0L;
        File[] files = file.listFiles();
        for (File file1 : files) {
            if(file1.isFile()){
                size+=file1.length();
            }else {
                size+=calculate(file);
            }
        }
        return size;
    }
}
